import java.util.Arrays;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 04 - 18
 * Time: 11:40
 */
//调整数组顺序使得奇数位于偶数之前
public class test1 {
    public static void main(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5, 6, 8, 12};
        int[] arr2 = new int[8];
        int j = 0;
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] % 2 == 1) {
                arr2[j++] = arr1[i];
            }
        }
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] % 2 == 0) {
                arr2[j++] = arr1[i];
            }
        }
        System.out.println(Arrays.toString(arr2));
    }
}
